<template>
  <div>
    <div>
      <!-- 面包屑导航 -->
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">招聘管理</el-breadcrumb-item>
        <el-breadcrumb-item>招聘需求</el-breadcrumb-item>
      </el-breadcrumb>
      <br>
      <br>
      <!-- 搜索筛选 -->
      <el-form :inline="true"
               class="user-search">
        <el-form-item label="搜索：">
          <select class="se_input"
                  v-model="formInline.lin_departmentname">
            <option selected
                    value="所属组织">所属组织</option>
            <option value="技术中心">技术中心</option>
            <option value="运营中心">运营中心</option>
            <option value="客服中心">客服中心</option>
            <option value="管理中心">管理中心</option>
          </select>
        </el-form-item>

        <el-form-item>
          <select v-model="formInline.lin_recruittype"
                  class="se_input">
            <option selected
                    value="招聘类型">招聘类型</option>
            <option value="校园招聘">校园招聘</option>
            <option value="社会招聘">社会招聘</option>
          </select>
        </el-form-item>

        <el-form-item>
          <select v-model="formInline.lin_status"
                  class="se_input">
            <option selected
                    value="需求状态">需求状态</option>
            <option value="启用">启用</option>
            <option value="停用">停用</option>
          </select>
        </el-form-item>

        <el-form-item>
          <el-input size="small"
                    v-model="formInline.positionName"
                    placeholder="招聘职位名称"></el-input>
        </el-form-item>

        <el-form-item style="position: relative;left: 200px;">
          <el-button size="small"
                     type="primary"
                     icon="el-icon-search"
                     @click="search">搜索</el-button>
          <el-button size="small"
                     type="primary"
                     icon="el-icon-edit"
                     @click="flush">重置</el-button>
        </el-form-item>
      </el-form>

      <!-- 分割线 -->
      <el-divider></el-divider>
      <el-form>
        <el-form-item>
          <el-button size="small"
                     type="primary"
                     icon="el-icon-plus"
                     @click="handleEdit()">新增</el-button>
          <el-button size="small"
                     type="primary"
                     icon="el-icon-upload el-icon--right">导出</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div style="margin-top: 10px">
      <!--列表-->
      <el-table size="small"
                :data="listData"
                highlight-current-row
                v-loading="loading"
                border
                element-loading-text="拼命加载中"
                style="width: 100%;">

        <el-table-column fixed
                         align="center"
                         type="selection"
                         width="60">
        </el-table-column>

        <el-table-column sortable
                         prop="needcode"
                         label="需求ID"
                         fixed
                         width="110">
        </el-table-column>

        <el-table-column sortable
                         fixed
                         prop="organizationName"
                         label="招聘机构"
                         width="160">
        </el-table-column>

        <el-table-column sortable
                         prop="recruittype"
                         label="招聘类型"
                         width="160">
        </el-table-column>

        <el-table-column sortable
                         prop="departmentname"
                         label="所属组织"
                         width="160">
        </el-table-column>

        <el-table-column sortable
                         prop="positionid"
                         label="职位编码"
                         width="110">
        </el-table-column>

        <el-table-column sortable
                         prop="positionName"
                         label="职位名称"
                         width="160">
        </el-table-column>

        <el-table-column sortable
                         prop="jobers"
                         label="招聘人数"
                         width="110">
        </el-table-column>

        <el-table-column sortable
                         prop="cityname"
                         label="工作地区"
                         width="110">
        </el-table-column>

        <el-table-column sortable
                         prop="language"
                         label="语言要求"
                         width="110">
        </el-table-column>

        <el-table-column sortable
                         prop="salary"
                         label="职位月薪"
                         width="110">
        </el-table-column>

        <el-table-column sortable
                         prop="gender"
                         label="性别要求"
                         width="110">
        </el-table-column>

        <el-table-column sortable
                         prop="wtime"
                         label="申请日期"
                         width="110">
        </el-table-column>

        <el-table-column sortable
                         prop="wontime"
                         label="要求到岗日期"
                         width="150">
        </el-table-column>

        <el-table-column sortable
                         prop="status"
                         label="需求状态"
                         width="110">
        </el-table-column>

        <el-table-column align="center"
                         label="操作"
                         fixed="right"
                         min-width="200">
          <template slot-scope="scope">
            <el-button size="mini"
                       @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
            <el-button size="mini"
                       type="danger"
                       @click="deleteUser(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页组件 -->
      <Pagination v-bind:child-msg="pageparm"
                  @callFather="callFather"
                  style="position: relative;top: 1px;"></Pagination>
    </div>

    <!-- 编辑界面 -->
    <el-dialog :title="title"
               :visible.sync="editFormVisible"
               width="60%"
               @click="closeDialog">
      <div style="display:flex;flex-direction:row">

        <div>

          <el-form label-width="120px"
                   :model="editForm"
                   :rules="rules"
                   ref="editForm">
         <el-row>
             <el-col :span="12">
            <div>

              <el-form-item label="招聘需求ID">
                <el-input size="small"
                          v-model="editForm.needcode"
                          
                          :disabled="true"></el-input>
              </el-form-item>

              <el-form-item label="招聘机构"
                            prop="departmentname">
                <div class="main">
                  <el-popover class="select-tree"
                              width="300"
                              placement="bottom-start"
                              trigger="click"
                              v-model="visible"
                              >

                    <el-input ref="input"
                              slot="reference"
                              placeholder="请选择"
                              v-model="editForm.departmentname"
                              size="small"
                              clearable
                              @input="treeFilter"
                              @clear="clear" />

                    <el-tree ref="tree"
                             class="tree"
                             :data="hostdepartment"
                             :props="defaultProps"
                             :expand-on-click-node="false"
                             node-key="id"
                             @node-click="handleNodeClick" />

                  </el-popover>
                </div>

              </el-form-item>

              <el-form-item label="招聘职位ID"
                            prop="positioncode">

                <el-input size="small"
                          v-model="editForm.positioncode"
                          
                          style="width: 300px;"
                          @focus='positionMethod()'>
                </el-input>

              </el-form-item>

              <el-form-item label="招聘职位名称"
                            prop="positionName">
                <el-input size="small"
                          v-model="editForm.positionName"
                          auto-complete="off"
                          :disabled="true"
                          style="width: 300px;"></el-input>
              </el-form-item>

              <el-form-item label="学历要求"
                            prop="educationfrom">
                <el-dropdown @command="geteducation"
                             divided
                             style="width: 300px;">

                  <el-input v-model="editForm.educationfrom">
                  </el-input>
                  <el-dropdown-menu slot="dropdown"
                                    style="width: 300px">
                    <el-dropdown-item :command='item'
                                      v-for="item in hostEducation"
                                      :key="item.eid">
                      {{item.name}}
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </el-form-item>

              <el-form-item label="工作年限"
                            prop="wtime">
                <select name=""
                        class="se_input"
                        v-model="editForm.wtime"
                        style="width: 300px;">
                  <option selected
                          value="不限">不限</option>
                  <option value="一年以下">一年以下</option>
                  <option value="一年以上">一年以上</option>
                  <option value="两年以下">两年以下</option>
                  <option value="两年以上">两年以上</option>
                  <option value="三年以上">三年以上</option>
                  <option value="五年以上">五年以上</option>
                  <option value="八年以上">八年以上</option>
                  <option value="十年以上">十年以上</option>
                </select>
              </el-form-item>

              <el-form-item label="婚姻要求"
                            prop="marriage">
                <select v-model="editForm.marriage"
                        class="se_input"
                        style="width: 300px;">
                  <option selected
                          value="不限">不限</option>
                  <option value="已婚">已婚</option>
                  <option value="未婚">未婚</option>
                </select>
              </el-form-item>

              <el-form-item label="语言要求"
                            prop="languagefrom">
                <el-dropdown @command="getlanguage"
                             divided
                             style="width: 300px;">

                  <el-input v-model="editForm.languagefrom">
                  </el-input>
                  <el-dropdown-menu slot="dropdown"
                                    style="width: 300px">
                    <el-dropdown-item :command='item'
                                      v-for="item in hostLanguage"
                                      :key="item.id">
                      {{item.name}}
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </el-form-item>

              <el-form-item label="工作工区"
                            prop="wplacefrom">
                <el-dropdown @command="getwplace"
                             divided
                             style="width: 300px;">
                  <el-input v-model="editForm.wplacefrom">
                  </el-input>
                  <el-dropdown-menu slot="dropdown"
                                    style="width: 300px">
                    <el-dropdown-item :command='item'
                                      v-for="item in hostwplace"
                                      :key="item.id">
                      {{item.name}}
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </el-form-item>

              <el-form-item label="申请人"
                            prop="applicant">
                <el-input size="small"
                          v-model="editForm.applicant"
                          auto-complete="off"
                          placeholder="请填写申请人"
                          style="width: 300px;"></el-input>
              </el-form-item>

              <el-form-item label="要求到岗日期"
                            prop="wontime">
                <el-date-picker type="datetime"
                                placeholder="选择日期"
                                value-format="yyyy-MM-dd hh:mm:ss"
                                v-model="editForm.wontime"
                                style="width: 300px;"></el-date-picker>
              </el-form-item>

              <el-form-item label="职责描述"
                            prop="responsiblities">
                <el-input type="textarea"
                          v-model="editForm.responsiblities"
                          auto-complete="off"
                          placeholder="请输入职责描述"
                          style="width: 300px;"
                          maxlength="500"
                          show-word-limit
                          :autosize="{ minRows: 8, maxRows: 16}">
                </el-input>
              </el-form-item>

              <el-form-item label="创建人"
                            prop="establishPerson">
                <el-input size="small"
                          v-model="editForm.establishPerson"
                          auto-complete="off"
                          placeholder="admin"
                          :disabled="true"
                          style="width: 300px;"></el-input>
              </el-form-item>
            </div>
            </el-col>
            <el-col :span="6">
            <div>
              <el-form-item label="招聘类型"
                            prop="recruittype">
                <select v-model="editForm.recruittype"
                        class="se_input"
                        style="width: 300px;">
                  <option selected
                          value="社会招聘">社会招聘</option>
                  <option value="校园招聘">校园招聘</option>
                </select>
              </el-form-item>

              <el-form-item label="所属组织"
                            prop="ssdepartment">
                <el-input size="small"
                          v-model="editForm.ssdepartment"
                          auto-complete="off"
                          :disabled="true"
                          style="width: 300px;"></el-input>
              </el-form-item>

              <el-form-item label="招聘职位编码"
                            prop="jobcode">
                <el-input size="small"
                          v-model="editForm.jobcode"
                          auto-complete="off"
                          placeholder="T4332"
                          :disabled="true"
                          style="width: 300px;"></el-input>
              </el-form-item>

              <el-form-item label="招聘人数"
                            prop="jobers">
                <el-input size="small"
                          v-model="editForm.jobers"
                          auto-complete="off"
                          placeholder="请输入招聘人数"
                          style="width: 300px;"></el-input>
              </el-form-item>

              <el-form-item label="专业要求"
                            prop="major">
                <el-input size="small"
                          v-model="editForm.major"
                          auto-complete="off"
                          placeholder="请输入专业要求"
                          style="width: 300px;"></el-input>
              </el-form-item>

              <el-form-item label="年龄要求"
                            prop="age">
                <select v-model="editForm.age"
                        class="se_input"
                        style="width: 300px;">
                  <option selected
                          value="不限">不限</option>
                  <option value="20岁以内">20岁以内</option>
                  <option value="20-30岁">20-30岁</option>
                  <option value="30-40岁">30-40岁</option>
                  <option value="40-50岁">40-50岁</option>
                  <option value="50岁以上">50岁以上</option>
                </select>
              </el-form-item>

              <el-form-item label="性别要求"
                            prop="gender">
                <select v-model="editForm.gender"
                        class="se_input"
                        style="width: 300px;">
                  <option selected
                          value="不限">不限</option>
                  <option value="男">男</option>
                  <option value="女">女</option>
                </select>
              </el-form-item>

              <el-form-item label="职位月薪"
                            prop="salary">
                <select v-model="editForm.salary"
                        class="se_input"
                        style="width: 300px;">
                  <option selected
                          value="面议">面议</option>
                  <option value="1000元以下">1000元以下</option>
                  <option value="1000-2000">1000-2000</option>
                  <option value="2000-4000">2000-4000</option>
                  <option value="4000-6000">4000-6000</option>
                  <option value="6000-8000">6000-8000</option>
                  <option value="8000-10000">8000-10000</option>
                  <option value="10000-15000">10000-15000</option>
                  <option value="15000-20000">15000-20000</option>
                  <option value="20000-30000">20000-30000</option>
                  <option value="30000-50000">30000-50000</option>
                  <option value="50000以上">50000以上</option>
                </select>
              </el-form-item>

              <el-form-item label="需求状态"
                            prop="status">
                <select v-model="editForm.status"
                        class="se_input"
                        style="width: 300px;">
                  <option selected
                          value="启用">启用</option>
                  <option value="停用">停用</option>
                </select>
              </el-form-item>

              <el-form-item label="申请日期"
                            prop="applytime">
                <el-date-picker type="datetime"
                                placeholder="选择时间"
                                value-format="yyyy-MM-dd hh:mm:ss"
                                v-model="editForm.applytime"
                                style="width: 300px;"></el-date-picker>
              </el-form-item>

              <el-form-item label="完成日期"
                            prop="finishtime">
                <el-date-picker type="datetime"
                                placeholder="选择时间"
                                value-format="yyyy-MM-dd hh:mm:ss"
                                v-model="editForm.finishtime"
                                style="width: 300px;"></el-date-picker>
              </el-form-item>

              <el-form-item label="任职资格"
                            prop="qualification">

                <el-input type="textarea"
                          v-model="editForm.qualification"
                          auto-complete="off"
                          placeholder="请输入任职资格"
                          style="width: 300px;"
                          maxlength="500"
                          show-word-limit
                          :autosize="{ minRows: 8, maxRows: 16}">

                </el-input>
              </el-form-item>

              <el-form-item label="创建时间"
                            prop="establishTime">
                <el-input size="small"
                          v-model="editFormTwo.establishTime"
                          auto-complete="off"
                          placeholder="2018-01-01 12:12:12"
                          :disabled="true"
                          style="width: 300px;"></el-input>
              </el-form-item>
            </div>
            </el-col>
         </el-row>
          </el-form>
        </div>
      </div>


      <div slot="footer"
           class="dialog-footer"
           >
        <el-button size="small"
                   @click="closeDialog">取消</el-button>
        <el-button size="small"
                   type="primary"
                   :loading="loading"
                   class="title"
                   @click="submitForm('editForm')">保存</el-button>
      </div>

      <!-- 招聘职位ID -->
    </el-dialog>
    <el-dialog title="请选择职位ID"
               width="60%"
               :visible.sync="selectWindow">
      <el-table :data="positionGetSelect"
                height="380px"
                @selection-change="positionChange">

        <el-table-column align="center"
                         type="selection"
                         width="60">
        </el-table-column>

        <el-table-column sortable
                         prop="id"
                         label="序号"
                         width="80">
        </el-table-column>
        <el-table-column sortable
                         prop="code"
                         label="职位ID"
                         width="100">
        </el-table-column>
        <el-table-column sortable
                         prop="positionName"
                         label="职位名称"
                         width="150">
        </el-table-column>
        <el-table-column sortable
                         prop="leveCode"
                         label="职类别编码"
                         width="150">
        </el-table-column>
        <el-table-column sortable
                         prop="categoryName"
                         label="职位类别名称"
                         width="150">
        </el-table-column>
        <el-table-column sortable
                         prop="organizationName"
                         label="组织名称"
                         width="150">
        </el-table-column>
      </el-table>

      <div slot="footer"
           class="dialog-footer">
        <el-button type="primary"
                   @click="positonExcel">确定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import Pagination from '../../components/Pagination'
export default {
  data() {
    return {
      visible: false, // 显示下拉窗
      text: '', // 选中值-中文
      hostEducation: [], //学历
      hostLanguage: [], //语言
      hostwplace: [], //工作工区
      hostdepartment: [], //组织
      defaultProps: {
        children: 'children',
        label: 'organizationName',
      }, //组织
      nshow: true, //switch开启
      fshow: false, //switch关闭
      loading: false, //是显示加载
      editFormVisible: false, //控制编辑页面显示与隐藏
      selectWindow: false, //控制招聘职位ID页面的显示与隐藏
      positionSelect: [], //选择后的数据
      positionGetSelect: [], //获取招聘职位ID页面的数据
      title: '添加',
      editForm: {
        nid: '',
        needcode: '',
        departmentname: '', //招聘机构组织名称
        departmentId: '', //招聘机构id
        positioncode: '', //职位编码id
        positionId: '', //职位主键id
        positionName: '', //职位名称
        cityname: '', //申请时间
        education: '', //学历id
        educationfrom: '', //学历
        languageId: '', //语言要求id
        languagefrom: '', //语言要求
        wplaceId: '', //工作工区id
        wplacefrom: '', //工作工区
        salary: '', //职位月薪
        wtime: '', //工作年限
        marriage: '', //婚姻要求
        applicant: '', //申请人
        wontime: '', //要求到岗时间
        responsiblities: '', //职责描述

        recruittype: '', //招聘类型
        ssdepartment: '', //所属组织
        jobcode: '', //职位编码
        jobers: '', //招聘人数
        major: '', //专业要求
        age: '', //年龄要求
        gender: '', //性别要求
        salary: '', //职位月薪
        status: '', //需求状态
        applytime: '', //申请日期
        finishtime: '', //需求完成时间
        qualification: '', //任职资格
        establishTime: '', //创建时间
      },
      editFormTwo: {},

      // rules表单验证
      rules: {
        // educationfrom: [
        //   { required: true, message: '请选择学历要求', trigger: 'blur' },
        // ],
        wtime: [{ required: true, message: '请选择工作年限', trigger: 'blur' }],
        marriage: [
          { required: true, message: '请选择婚姻要求', trigger: 'blur' },
        ],
        // languagefrom: [
        //   { required: true, message: '请选择语言要求', trigger: 'blur' },
        // ],
        // wplacefrom: [
        //   { required: true, message: '请选择工作工区', trigger: 'blur' },
        // ],
        applicant: [
          { required: true, message: '请填写申请人', trigger: 'blur' },
        ],
        wontime: [
          { required: true, message: '请选择要求到岗日期', trigger: 'blur' },
        ],
        responsiblities: [
          { required: true, message: '请输入职责描述', trigger: 'blur' },
        ],

        recruittype: [
          { required: true, message: '请选择招聘类型', trigger: 'blur' },
        ],
        positionId: [
          { required: true, message: '请选择职位ID', trigger: 'blur' },
        ],
        jobers: [
          { required: true, message: '请输入招聘人数', trigger: 'blur' },
        ],
        major: [{ required: true, message: '请输入专业要求', trigger: 'blur' }],
        gender: [
          { required: true, message: '请选择年龄要求', trigger: 'blur' },
        ],
        gender: [{ required: true, message: '请选择性别', trigger: 'blur' }],
        salary: [
          { required: true, message: '请选择职位月薪', trigger: 'blur' },
        ],
        status: [
          { required: true, message: '请选择需求状态', trigger: 'blur' },
        ],
        applytime: [
          { required: true, message: '请选择申请时间', trigger: 'blur' },
        ],
        finishtime: [
          { required: true, message: '请选择需求完成日期', trigger: 'blur' },
        ],
        qualification: [
          { required: true, message: '请输入任职资格', trigger: 'blur' },
        ],
      },
      formInline: {
        page: 1,
        limit: 10,
        varLable: '',
        varName: '',
        departmentname: '', //所属组织
        recruittype: '', //招聘类型
        status: '', //需求状态
        lin_departmentname: '所属组织', //所属组织
        lin_recruittype: '招聘类型', //招聘类型
        positionName: '', //招聘职位名称
        lin_status: '需求状态',
      },
      // 逻辑删除招聘渠道
      seletedata: {
        ids: '',
      },
      userparm: [], //搜索权限
      listData: [], //用户数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 2,
        total: 10,
      },
    }
  },
  // 注册组件
  components: {
    Pagination,
  },
  created() {
    this.getdata(this.formInline)
    this.setEducation()
    this.setlanguage()
    this.setwplace()
    this.setdepartment()
  },

  /**
   * 里面的方法只有被调用才会执行
   */
  methods: {
    //招聘职位ID页面显示方法
    positionMethod() {
      this.selectWindow = true
      this.$axios.get('/recuitmentNeed/findPostionId/').then((res) => {
        if (res.code == 200) {
          this.positionGetSelect = res.obj
        }
      })
    },
    //点击确定方法
    positonExcel() {
      if (this.positionSelect.length < 1) {
        this.$message.error('请选择职位！')
        return false
      }
      if (this.positionSelect.length > 2) {
        this.$message.error('请选择一个职位！')
        return false
      }
      if (this.positionSelect.length == 2) {
        this.$message.error('请选择一个职位！')
        return false
      }
      this.selectWindow = false
      console.log(this.positionSelect)
      this.editForm.positioncode = this.positionSelect[0].code
      this.editForm.positionId = this.positionSelect[0].id
      this.editForm.positionName = this.positionSelect[0].positionName
      this.editForm.jobcode = this.positionSelect[0].code
    },
    //选中招聘职位的数据
    positionChange(val) {
      this.positionSelect = val
    },
    //学历要求
    geteducation(command) {
      this.editForm.educationfrom = command.name
      this.editForm.education = command.eid
    },
    //语言要求
    getlanguage(command) {
      this.editForm.languageId = command.id
      this.editForm.languagefrom = command.name
      console.log(this.editForm.languagefrom);
    },
    //工作工区
    getwplace(command) {
      this.editForm.wplaceId = command.id
      this.editForm.wplacefrom = command.name
    },
    
    //发送请求得到后端学历
    setEducation() {
      if (!window.sessionStorage.getItem('hotEducation')) {
        this.$axios.get('/recuitmentNeed/findEducationId/').then((res) => {
          if (res) {
            this.hostEducation = res
            window.sessionStorage.setItem('hotEducation', JSON.stringify(res))
          }
        })
      } else {
        this.hostEducation = JSON.parse(
          window.sessionStorage.getItem('hotEducation')
        )
      }
    },
    //发送请求得到后端语言要求
    setlanguage() {
      if (!window.sessionStorage.getItem('hotLanguage')) {
        this.$axios.get('/recuitmentNeed/findLangaueId/').then((res) => {
          if (res) {
            this.hostLanguage = res
            window.sessionStorage.setItem('hotLanguage', JSON.stringify(res))
          }
        })
      } else {
        this.hostLanguage = JSON.parse(
          window.sessionStorage.getItem('hotLanguage')
        )
      }
    },
    //发送请求得到后端工作工区
    setwplace() {
      if (!window.sessionStorage.getItem('hotwplace')) {
        this.$axios.get('/recuitmentNeed/findCitiesId/').then((res) => {
          if (res) {
            this.hostwplace = res
            window.sessionStorage.setItem('hotwplace', JSON.stringify(res))
          }
        })
      } else {
        this.hostwplace = JSON.parse(window.sessionStorage.getItem('hotwplace'))
      }
    },
    //发送请求得到后端组织结构
    setdepartment() {
      if (!window.sessionStorage.getItem('hotdepartment')) {
        this.$axios.get('/recuitmentNeed/findDepartId/').then((res) => {
          if (res) {
            this.hostdepartment = res
            window.sessionStorage.setItem('hotdepartment', JSON.stringify(res))
          }
        })
      } else {
        this.hostdepartment = JSON.parse(
          window.sessionStorage.getItem('hotdepartment')
        )
      }
    },
    // 查询全部
    getdata(parameter) {
      this.loading = true
      // 模拟数据开始
      let res = {
        code: 0,
        msg: null,
        count: 5,
      }
      this.loading = false
      this.pageparm.currentPage = this.formInline.page
      this.pageparm.pageSize = this.formInline.limit

      /***
       * 调用接口，注释上面模拟数据 取消下面注释
       */
      if (this.formInline.lin_departmentname == '所属组织') {
        this.formInline.departmentname = ''
      } else {
        this.formInline.departmentname = this.formInline.lin_departmentname
      }
      if (this.formInline.lin_recruittype == '招聘类型') {
        this.formInline.recruittype = ''
      } else {
        this.formInline.recruittype = this.formInline.lin_recruittype
      }
      if (this.formInline.lin_status == '需求状态') {
        this.formInline.status = ''
      } else {
        this.formInline.status = this.formInline.lin_status
      }
      this.$axios
        .post(
          '/recuitmentNeed/find/' +
            this.pageparm.currentPage +
            '/' +
            this.pageparm.pageSize,
          this.formInline
        )
        .then((res) => {
          this.loading = false
          if (res.code == 200) {
            this.listData = res.obj.records
            this.pageparm.currentPage = res.obj.current
            this.pageparm.pageSize = res.obj.size
            this.pageparm.total = res.obj.total
            // console.log(this.listData);
          } else {
            this.$message({
              type: 'error',
              message: res.msg,
            })
          }
        })
    },
    // 分页插件事件
    callFather(parm) {
      this.formInline.page = parm.currentPage
      this.formInline.limit = parm.pageSize
      this.getdata(this.formInline)
    },
    // 搜索事件
    search() {
      this.getdata(this.formInline)
    },
    //显示编辑界面
    handleEdit: function (index, row) {
      this.editFormVisible = true
      if (row != undefined && row != 'undefined') {
        console.log(row)
        this.title = '修改'
        this.editForm.nid = row.nid
        this.editForm.needcode = row.needcode
        this.editForm.departmentname = row.departmentname
        this.editForm.positioncode = row.positionid
        this.editForm.jobcode = row.positionid
        this.editForm.positionName = row.positionName
        this.editForm.educationfrom = row.education
        this.editForm.wtime = row.wtime
        this.editForm.languagefrom = row.language
        this.editForm.wplacefrom = row.cityname
        this.editForm.wontime = row.wontime
        this.editForm.recruittype = row.recruittype
        this.editForm.ssdepartment = row.organizationName
        this.editForm.gender = row.gender
        this.editForm.salary = row.salary
        this.editForm.status = row.status
        this.editForm.finishtime = row.finishtime
        this.editForm.marriage = row.marriage
        this.editForm.applicant = row.applicant
        this.editForm.responsiblities = row.responsiblities
        this.editForm.major = row.major
        this.editForm.age = row.age
        this.editForm.applytime = row.applytime
        this.editForm.qualification = row.qualification
        this.editForm.educationfrom = row.educationname
        this.editForm.jobers = row.jobers

        this.editForm.addOr = 'edit'
      } else {
        this.title = '添加'
        this.editForm.needcode = '0'
        this.editForm.departmentId = ''
        this.editForm.positionId = ''
        this.editForm.positionName = ''
        this.editForm.education = ''
        this.editForm.wtime = '不限'
        this.editForm.marriage = '不限'
        this.editForm.languageId = ''
        this.editForm.wplaceId = ''
        this.editForm.applicant = ''
        this.editForm.wontime = ''
        this.editForm.responsiblities = ''
        this.editForm.recruittype = '社会招聘'
        this.editForm.ssdepartment = ''
        this.editForm.jobcode = ''
        this.editForm.jobers = ''
        this.editForm.major = ''
        this.editForm.gender = '不限'
        this.editForm.age = '不限'
        this.editForm.salary = '面议'
        this.editForm.status = '启用'
        this.editForm.applytime = ''
        this.editForm.finishtime = ''
        this.editForm.qualification = ''
        this.editForm.addOr = 'add'
      }
    },

    flush() {
      ;(this.formInline.lin_departmentname = '所属组织'),
        (this.formInline.lin_recruittype = '招聘类型'),
        (this.formInline.lin_status = '需求状态'),
        (this.formInline.departmentname = '所属组织'),
        (this.formInline.recruittype = '招聘类型'),
        (this.formInline.status = '需求状态'),
        (this.formInline.positionName = ''),
        this.getdata(this.formInline)
    },
    // 编辑、增加页面保存方法
    submitForm(editData) {
      this.$refs[editData].validate((valid) => {
        if (valid) {
          if (this.editForm.addOr == 'add') {
               this.$confirm('确定要保存吗?', '信息', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
            this.$axios
              .post('/recuitmentNeed/needAdd/', this.editForm)
              .then((res) => {
                console.log(res)
                if (res.code == 200) {
                  this.getdata(this.formInline)
                  this.editFormVisible = false
                } else {
                  this.editFormVisible = false
                }
              })
              .catch()
      })
          }
          if (this.editForm.addOr == 'edit') {
               this.$confirm('确定要修改吗?', '信息', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
            this.$axios
              .put('/recuitmentNeed/updateDelte/', this.editForm)
              .then((res) => {
                console.log(res)
                if (res.code == 200) {
                  //修改成功后在刷新页面
                  this.getdata(this.formInline)
                  //关闭修改框
                  this.editFormVisible = false
                } else {
                  //关闭修改框
                  this.editFormVisible = false
                }
              })
              .catch()

          })
          }
        } else {
          return false
        }
      })
    },
    // 删除公司
    deleteUser(index, row) {
      this.$confirm('确定要删除吗?', '信息', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.$axios
            .delete('/recuitmentNeed/needDelte/' + row.nid)
            .then((res) => {
              if (res.code == 200) {
                this.$message({
                  type: 'success',
                  message: res.message,
                })
                //重新渲染列表
                this.getdata(this.formInline)
              } else {
                this.$message({
                  type: 'success',
                  message: res.message,
                })
              }
            })
            .catch((err) => {
              this.loading = false
              this.$message.error('用户删除失败，请稍后再试！')
            })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除',
          })
        })
    },
    // 关闭编辑、增加弹出框
    closeDialog() {
         this.$confirm('确定要取消吗?', '信息', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
      this.editFormVisible = false
      this.editForm={
          nid: '',
        needcode: '',
        departmentname: '', //招聘机构组织名称
        departmentId: '', //招聘机构id
        positioncode: '', //职位编码id
        positionId: '', //职位主键id
        positionName: '', //职位名称
        cityname: '', //申请时间
        education: '', //学历id
        educationfrom: '', //学历
        languageId: '', //语言要求id
        languagefrom: '', //语言要求
        wplaceId: '', //工作工区id
        wplacefrom: '', //工作工区
        salary: '', //职位月薪
        wtime: '', //工作年限
        marriage: '', //婚姻要求
        applicant: '', //申请人
        wontime: '', //要求到岗时间
        responsiblities: '', //职责描述

        recruittype: '', //招聘类型
        ssdepartment: '', //所属组织
        jobcode: '', //职位编码
        jobers: '', //招聘人数
        major: '', //专业要求
        age: '', //年龄要求
        gender: '', //性别要求
        salary: '', //职位月薪
        status: '', //需求状态
        applytime: '', //申请日期
        finishtime: '', //需求完成时间
        qualification: '', //任职资格
        establishTime: '', //创建时间
      }
      })
    },

    clear() {
      this.$refs.tree.setCurrentKey(null)
      this.text = ''
    },
    treeFilter(val) {
      this.visible = true
      this.$refs.tree.filter(val)
      if (val == '') {
        this.$refs.tree.setCurrentKey(null)
      }
    },
    // 点击回调
    handleNodeClick(node) {
      if (node.disable) {
        return false
      }
      this.visible = false
      this.editForm.departmentname = node.organizationName
    //   this.text = node.organizationName
      this.editForm.ssdepartment = node.organizationName
      this.editForm.departmentId = node.id
    },
  },
}
</script>

<style scoped lang="less">
.se_input {
  position: relative;
  left: 0px;
  top: 0px;
  width: 190px;
  height: 30px;
  font-family: 'Arial Normal', 'Arial';
  font-weight: 400;
  font-style: normal;
  font-size: 14px;
  text-decoration: none;
  color: #000000;
}
#status_input {
  position: relative;
  left: 20px;
}
.main {
  width: 300px;
  margin: 0 auto;
  .select-tree {
    width: 500px;
    max-height: 350px;
    overflow: auto;
    .el-tree-node.is-current > .el-tree-node__content {
      background: rgba(236, 245, 255, 0.8);
      color: #409eff;
    }
  }
}
</style>